package mobi.hami.huapin.dao;

import java.util.List;

import mobi.hami.huapin.daobase.CrudMapper;
import mobi.hami.huapin.model.SkuAttribute;
import mobi.hami.huapin.model.SkuAttributevalue;
import mobi.hami.huapin.model.SkuAttributevalueExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface SkuAttributevalueMapper  extends CrudMapper<SkuAttributevalue> {
    // @Select("SELECT * FROM sku_attributevalue  where productid=#{productid}")#{_parameter,jdbcType=INTEGER}
    @Select("<script>"
            + "SELECT * FROM sku_attributevalue "
            + "<where>"
            + "<if test='_parameter >0'>AND productid = #{_parameter}</if>"
            + "</where>"
            + "</script>")
    List<SkuAttributevalue> getAttributeVslueByProductid(Integer Productid);

    @Select("<script>"
            + "SELECT * FROM sku_attributevalue "
            + "<where>"
            + "<if test='_parameter >0'>AND skuattribute = #{_parameter}</if>"
            + "</where>"
            + "</script>")
    List<SkuAttributevalue> getattribute_byvalueid(int skuattribute);

    /**
     * 用户前端查询 销售属性值
     * @param spu_id
     * @return
     */
    @Select("SELECT id,productid,name,skuattribute from sku_attributevalue where productid = #{spu_id} order by displayorder asc  ")
    public List<SkuAttributevalue> getListForUser(long spu_id);

}